package pei.lei.lostandfound.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.format.annotation.DateTimeFormat;
import pei.lei.lostandfound.entity.Notice;
import pei.lei.lostandfound.entity.UserInfo;

import javax.persistence.Column;
import javax.persistence.Id;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * @auther zhang
 * @ TO DO
 * @creatTime 2021/1/19 17:25
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class NoticeDTO implements Serializable {


    /*
     * 发布的用户id
     */
    @Column(name = "user_id")
    private String userId;

    /**
     * 用户名
     */
    @Column(name = "user_name")
    private String userName;

    /**
     * 联系方式
     */
    @Column(name = "callphone")
    private String callphone;

    /**
     * 0是女，1是男
     */
    @Column(name = "gender")
    private Integer gender;

    /**
     * 失物招领订单id
     */
    @Id
    @Column(name = "notice_id")
    private Integer noticeId;



    /**
     * 订单类型，0是失物，1是拾物
     */
    @Column(name = "order_type")
    private String orderType;

    /**
     * 东西捡到的位置
     */
    @Column(name = "address")
    private String address;

    /**
     * 东西名字
     */
    @Column(name = "thing_name")
    private String thingName;

    /**
     * 信息详情
     */
    @Column(name = "order_message")
    private String orderMessage;

    /**
     * 上传的图片的url
     */
    @Column(name = "file_url")
    private String fileUrl;

    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = "YYYY-MM-DD:hh:mm")
    @Column(name = "creat_time")
    private Date creatTime;

    /**
     * 状态码，0是发布，1是举报，2已解决,3下架
     */
    @Column(name = "state")
    private String state;
    public NoticeDTO(Notice notice, UserInfo userInfo) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        PropertyUtils.copyProperties(this, userInfo);
        PropertyUtils.copyProperties(this, notice);

    }

}
